<!DOCTYPE html>
<%@page language="java" pageEncoding="utf-8" contentType="text/html; charset=UTF-8"%>
<%@page import="java.util.*,cn.nawang.ebeim.api.domain.User"%>

<%
	String ctx = request.getContextPath();
	User user=(User) request.getSession().getAttribute("user");
%>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>组织机构</title>
    <link rel="stylesheet" type="text/css" href="css/basic.css">
    <link rel="stylesheet" type="text/css" href="css/common.css">
    <link rel="stylesheet" type="text/css" href="css/ui.css">
    <!-- 设置JS全局变量  ctx -->
	<script type="text/javascript">
		var ctx = "<%=request.getContextPath()%>";
	</script>
</head>
<body>
    <jsp:include page="head.jsp"></jsp:include>
    <div class="container">
    <jsp:include page="user_left.jsp"></jsp:include>
        <div class="page-content">
            <div class="cont-area clearfix">
                <i class="fl"></i><span class="fl"><a href="index.jsp">首页</a>&gt;<a href="userlist.jsp">用户管理</a>&gt;组织机构</span>
            </div>
            <div class="wp20">
                <div id="depScroll">
                    <div class="deparment">
                        <div class="deparment-title">
                            部门管理
                        </div>
                        <div id="j-departTree">

                        </div>
                    </div>
                </div>
            </div>
            <div class="wp80">
                <div id="content-scroll">
                    <div class="data-grid">
                        <div class="grid-toolbar">
                            <div class="grid-title">
                                <p>用户管理</p>
                            </div>
                            <div class="search-box clearfix">
                                <div class="search-group">
                                    <label>真实姓名：</label>
                                    <input type="text" name="name" id="j-name">
                                </div>
                                <div class="search-group">
                                    <label>登录用户名：</label>
                                    <input type="text" name="username" id="j-username">
                                </div>

                                <div class="search-btns">
                                    <div class="long-search-btns">
                                        <button class="clearfix btn j-search" type="button"><i class="icos icos-search fl"></i><span class="fl">查询</span></button>
                                        <button class="clearfix btn j-reset" type="button"><i class="icos icos-reset fl"></i><span class="fl">重置</span></button>
                                        <!-- <button class="clearfix btn" type="button"><i class="icos icos-level fl"></i><span class="fl">高级查询</span></button> -->
                                    </div>
                                    <div class="short-search-btns">
                                        <button class="btn" type="button"><i class="icos icos-list"></i></button>
                                        <div class="btns-list">
                                            <ul>
                                                <li><a class="clearfix j-search" href="javascript:;">查询</a></li>
                                                <li><a class="clearfix j-reset" href="javascript:;">重置</a></li>
                                                <!-- <li><a class="clearfix" href="javascript:;">高级查询</a></li> -->
                                            </ul>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="thead">
                            <table>
                                <tbody>
                                    <tr>
                                        <th width="24px"><input class="j-checkAll" type="checkbox"></th>
                                        <th width="150px">编号</th>
                                        <th width="200px">真实姓名</th>
                                        <th width="200px">登录用户名</th>
                                        <th width="150px">用户状态</th>
                                        <th width="260px">操作区域</th>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                        <div class="tbody">
                            <table>
                                <tbody id="j-list">
                                <script type="text/ysmart" data-name="list">
                                    <@ yepjs.isArray(DATA.objList) && yepjs.forEach(DATA.objList, function(item, index){ @>
                                    <tr data-id="<@=item.id @>">
                                        <td width="24px"><input type="checkbox" data-id="<@=item.id @>" class="j-checkEach" /></td>
                                        <td width="150px"><@=item.id @></td>
                                        <td width="200px"><@=item.name @></td>
                                        <td width="200px"><@=item.username @></td>
                                        <td width="150px"><@=item.status @></td>
                                        <@ if (DATA.loginUser.role == "SYSADMIN" || DATA.loginUser.role == "ADMIN" || DATA.loginUser.id == item.id) { @>
										<td width="260px">
                                        	<a href="javascript:;" class="j-editUser">管理</a>
											<@ if ((DATA.loginUser.role == "SYSADMIN" || DATA.loginUser.role == "ADMIN") && DATA.loginUser.id != item.id) { @>
												<@ if (DATA.loginUser.availableSpaceSize > 0) { @>
												<a href="javascript:;" class="j-addToSpaceSize">追加空间</a>
												<@ }else{ @>
												<span style = "color:#999;">追加空间</span>
												<@ } @>
											<@ } @>
                                    	</td>
										<@ }else{ @>
										<td width="260px">
                                        	<a href="javascript:;" class="j-watchUser">查看详情</a>
                                    	</td>
										<@ } @>
                                    </tr>
                                    <@ }); @>
                                </script>
                                </tbody>
                            </table>
                        </div>
                        <div class="grid-page clearfix" id="j-page">
                            <div class="page-left fl"><span>共<span id="j-totalNum">0</span>条</span></div>
                            <div class="page-right fl">
                                <a href="javascript:;" class="j-page-first">首页</a>
                                <a href="javascript:;" class="j-page-prev">上一页</a>
                                <span>第<input type="text" value="1" class="j-page-cur">页，共<span class="j-page-totalPage">1</span>页</span>
                                <a href="javascript:;" class="j-page-next">下一页</a>
                                <a href="javascript:;" class="j-page-last">尾页</a>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script type="text/ysmart" data-name="userTpl">
        <div class="ui-dialog-form">
            <form>
				<div class="form-group">
                    <label><em>*</em>登录用户名：</label>
                    <input class="required" type="text" name="username" value="<@=DATA.username @>">
                    <span class="message msg-tip"><em></em><i>请输入登录用户名</i></span>
                </div>
                <div class="form-group">
                    <label><em>*</em>真实姓名：</label>
                    <input class="required" type="text" name="name" value="<@=DATA.name @>" />
                    <span class="message msg-tip"><em></em><i>请输入真实姓名</i></span>
                </div>
                <div class="form-group">
                    <label>用户状态：</label>
                    <select name="status">
                        <option value="0" <@ if (DATA.status == 0) { @>selected="selected"<@ } @>>正常</option>
                        <option value="1" <@ if (DATA.status == 1) { @>selected="selected"<@ } @>>停用</option>
                    </select>
                </div>
                <@if(!DATA.id){@>
                <div class="form-group">
                    <label><em>*</em>密码：</label>
                    <input class="required" type="password" name="password" value="">
                    <span class="message msg-tip"><em></em><i>请输入密码</i></span>
                </div>
                <@}@>
                <div class="form-group">
                    <label>所属机构：</label>
                    <div class="ui-treeSelect j-deptSelect">
                        <div class="j-treeSelectTitle ui-treeSelectTitle" >
                            <input class="j-treeSelectTxt" type="text" readonly="readonly" value="<@=DATA.departName @>">
                            <i class="ui-tree-ico ui-ico-drop"></i>
                        </div>
                        <div class="j-treeSelectList ui-treeSelectList">

                        </div>
                        <input type="hidden" name="departmentId" value="<@=DATA.departId @>" class="j-treeSelectValue" value="001" />
                    </div>
                </div>
                <div class="form-group">
                    <label><em>*</em>移动电话：</label>
                    <input class="required" type="text" name="mobile" value="<@=DATA.mobile @>">
                    <span class="message msg-tip"><em></em><i>请输入手机号</i></span>
                </div>
                <div class="form-group">
                    <label><em>*</em>电子邮件：</label>
                    <input class="required" type="text" name="email" value="<@=DATA.email @>">
                    <span class="message msg-tip"><em></em><i>请输入邮箱</i></span>
                </div>
                <input id="j-dataId" type="hidden" name="id" value="<@=DATA.id @>" />
            </form>
        </div>
    </script>
    <script type="text/ysmart" data-name="userinfoTpl">
        <div class="ui-dialog-userinfo clearfix">
            <div class="info-group">
                <label>用户编号:</label>
                <span><@=DATA.id @></span>
            </div>
			<div class="info-group">
                <label>登录用户名:</label>
                <span><@=DATA.username @></span>
            </div>
            <div class="info-group">
                <label>真实姓名:</label>
                <span><@=DATA.name @></span>
            </div>
            <div class="info-group">
                <label>用户状态:</label>
                <span><@=DATA.status @></span>
            </div>
            <div class="info-group">
                <label>移动电话:</label>
                <span><@=DATA.mobile @></span>
            </div>
            <div class="info-group">
                <label>部门:</label>
                <span><@=DATA.departName @></span>
            </div>
            <div class="info-group">
                <label>电子邮件:</label>
                <span><@=DATA.email @></span>
            </div>
        </div>
    </script>
    <script type="text/ysmart" data-name="editDepartTpl">
        <div class="ui-dialog-form">
            <form>
                <div class="form-group">
                    <label><em>*</em>部门名称：</label>
                    <input type="text" name="name" value="<@=DATA.text @>" />
                </div>
                <div class="form-group">
                    <label>排序：</label>
                    <input type="text" name="IOrder" value="<@=DATA.order @>" />
                </div>
                <input type="hidden" name="id" value="<@=DATA.id @>">
            </form>
        </div>
    </script>
    <script type="text/ysmart" data-name="addDepartTpl">
        <div class="ui-dialog-form">
            <form>
                <div class="form-group">
                    <label><em>*</em>部门名称：</label>
                    <input type="text" name="name" value="" />
                </div>
                <div class="form-group">
                    <label>排序：</label>
                    <input type="text" name="IOrder" value="0" />
                </div>
                <input type="hidden" name="parentId" value="<@=DATA.parentId @>">
            </form>
        </div>
    </script>
    <script type="text/ysmart" data-name="addToSpaceSizeTpl">
        <div class="ui-dialog-form">
            <form>
				<div class="form-group">
                    <label><em>*</em>追加空间：</label>
                    <input id="j-addToSpaceSize" class="required" type="text" name="spaceSize" value=""> G
                    <span class="message msg-tip"><em></em><i>请输入空间大小</i></span>
                </div>
                <input id="j-dataId" type="hidden" name="id" value=""/>
            </form>
        </div>
    </script>
    <div class="ui-tree-hover" id="j-treeHover">
        <!-- <div class="hover-list">
            <span class="j-menuitem" data-type="viewUser">查看用户</span>
        </div> -->
        <%
        	if(user!=null&&("SYSADMIN".equals(user.getRole())||"ADMIN".equals(user.getRole()))){
        %>
        <div class="hover-list">
            <span class="j-menuitem" data-type="addDepart">添加子部门</span>
        </div>
        <div class="hover-list">
            <span class="j-menuitem" data-type="edit">编辑</span>
        </div>
        <div class="hover-list" id="j-treeDelete">
            <span class="j-menuitem" data-type="del">删除</span>
        </div>
        <%
        	} 
        %>
    </div>
    <script src="js/yep.min.js" type="text/javascript" data-config="YBA.Config.js"></script>
    <script src="js/common.js" type="text/javascript"></script>
    <script type="text/javascript">
        yepjs.use({
            name: ["jquery", "YBA.Plugin.slimscroll","YBA.Common"],
            callback: function () {
                $('#side-scroll').slimscroll({
                    height:"100%"
                });
                $('#depScroll').slimscroll({
                    height:"100%"
                });
                YBA.Common.sidebar();
                YBA.Common.gridWidth();
            }
        });
        yepjs.use({
            name: "YBA.Logic.Department.list",
            callback: function () {
                YBA.Logic.Department.list();
            }
        });
    </script>
</body>
</html>
